<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Read session data</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sessionhandlerinterface.open.html">SessionHandlerInterface::open</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sessionhandlerinterface.write.html">SessionHandlerInterface::write</a></div>
 <div class="up"><a href="class.sessionhandlerinterface.html">SessionHandlerInterface</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="sessionhandlerinterface.read" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SessionHandlerInterface::read</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.4.0)</p><p class="refpurpose"><span class="refname">SessionHandlerInterface::read</span> &mdash; <span class="dc-title">Read session data</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-sessionhandlerinterface.read-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">abstract</span> <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><strong>SessionHandlerInterface::read</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$session_id</code></span>
   )</div>

  <p class="para rdfs-comment">
   Reads the session data from the session storage, and returns the results.
   Called right after the session starts or when <span class="function"><a href="function.session-start.html" class="function">session_start()</a></span> is called.
   Please note that before this method is called <span class="function"><a href="sessionhandlerinterface.open.html" class="function">SessionHandlerInterface::open()</a></span> is invoked.
  </p>
  <p class="para">
   This method is called by PHP itself when the session is started.
   This method should retrieve the session data from storage by the
   session ID provided. The string returned by this method must be in the same
   serialized format as when originally passed to the <span class="function"><a href="sessionhandlerinterface.write.html" class="function">SessionHandlerInterface::write()</a></span>
   If the record was not found, return an empty string.
  </p>
  <p class="para">
   The data returned by this method will be decoded internally by PHP using the
   unserialization method specified in <a href="session.configuration.html#ini.session.serialize-handler" class="link">session.serialize_handler</a>.
   The resultig data will be used to populate the <var class="varname"><var class="varname"><a href="reserved.variables.session.html" class="classname">$_SESSION</a></var></var> superglobal.
  </p>
  <p class="para">
   Note that the serialization scheme is not the same as <span class="function"><a href="function.unserialize.html" class="function">unserialize()</a></span>
   and can be accessed by <span class="function"><a href="function.session-decode.html" class="function">session_decode()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-sessionhandlerinterface.read-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">session_id</code></em></dt>

    <dd>

     <p class="para">
      The session id.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-sessionhandlerinterface.read-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an encoded string of the read data. If nothing was read, it must return an empty string. Note this value is returned internally to PHP for processing.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-sessionhandlerinterface.read-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member">
     The <a href="session.configuration.html#ini.session.serialize-handler" class="link">session.serialize_handler</a>
     configuration directive.
    </li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sessionhandlerinterface.open.html">SessionHandlerInterface::open</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sessionhandlerinterface.write.html">SessionHandlerInterface::write</a></div>
 <div class="up"><a href="class.sessionhandlerinterface.html">SessionHandlerInterface</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
